package cn.csc.module.pay.job.notify;

import cn.csc.framework.tenant.core.job.TenantJob;
import cn.csc.module.pay.service.notify.NotifyRefundLogService;
import cn.csc.module.pay.service.notify.PayNotifyService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 支付通知 Job
 * 通过不断扫描待通知的 PayNotifyTaskDO 记录，回调业务线的回调接口
 *
 * @author
 */
@Component
@TenantJob // 多租户
@Slf4j
public class PayNotifyJob {

    @Resource
    private PayNotifyService payNotifyCoreService;
    @Resource
    private NotifyRefundLogService notifyRefundLogService;


    @XxlJob("payNotifyJob")
    public ReturnT<String> payNotifyJob() throws Exception {
        int notifyCount = payNotifyCoreService.executeNotify();
        return new ReturnT<>(String.format("执行支付通知 %s 个", notifyCount));
    }

    @XxlJob("payNotifyrefundJob")
    public ReturnT<String> payNotifyrefundJob() throws Exception {
        int notifyCount = notifyRefundLogService.executeNotify();
        return new ReturnT<>(String.format("执行支付退款通知 %s 个", notifyCount));
    }

}
